Create database AssignmentPhotoBox
go
use AssignmentPhotoBox
go
create table Account(
	userid int primary key identity,
	username nvarchar(200) not null unique,
	password nvarchar(200) not null,
	fullname nvarchar(200) not null,
	dateOfBirth date not null,
	email nvarchar(200) not null,
	phonenumber nvarchar(50) not null,
	image nvarchar(200),
)
go
create proc CreateUser
	@username nvarchar(200),
	@password nvarchar(200),
	@fullname nvarchar(200),
	@dateOfBirth date,
	@email nvarchar(200),
	@phonenumber int,
	@image nvarchar(200)
as
insert into Account values(@username,@password,@fullname,@dateOfBirth,@email,@phonenumber,@image)
go
insert into Account values('kien','12345','trungkien','1/19/1993','kien@gmail.com',01626144293,'123.jpg')
go
insert into Account values('cuong','e10adc3949ba59abbe56e057f20f883e','manhcuong','10/10/1993','cuong@gmail.com',01626144293,'asd.jpg')
go
select * from Account
go



create table Img(
	id int primary key identity,
	imgName nvarchar(200) not null,
	dayshooting date not null,
	userid int foreign key references Account(userid),
	albumid int foreign key references Album(albumid),
	introduction nvarchar(500)
)
go
drop table Img
go
create table Album(
	albumid int primary key identity,
	albumname nvarchar(200),
	description nvarchar(200),
	datecreate date,
	username nvarchar(200) foreign key references Account(username)
)
go
create proc dangnhap
	@username nvarchar(200),
	@password nvarchar(200)
as
select userid, username, [password] from Account where username=@username and password=@password
go


create proc creatIamge
@imgName nvarchar(200),
@dayshooting date,
@userid int,
@albumid int,
@introduction nvarchar(500)
as
insert into Img values(@imgName,@dayshooting,@userid,@albumid,@introduction)
go
select * from Img
go

insert into Album values('abcd', 'sdcsdfdfsdf', '12/12/1992', 'cuong')
go
create proc CreateAlbum
@albumname nvarchar(200),
@description nvarchar(200),
@datecreate date,
@username nvarchar(200)
as
insert into Album values(@albumname,@description,@datecreate,@username)
go
create proc ShowAlbum
as
select * from Album
go

create proc getImage
as
select * from Img
go
drop proc getImage
go